package com.xli.sso.security;

import lombok.Getter;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JwtConfig {

    /**
     * 令牌
     */
    public static final String TOKEN = "token";

    /**
     * 令牌前缀
     */
    public static final String TOKEN_PREFIX = "Bearer ";

    /**
     * 令牌前缀
     */
    public static final String LOGIN_USER_KEY = "login_user_key";

    /**
     * 登录用户 redis key
     */
    public static final String LOGIN_TOKEN_KEY = "login_token_";

    public static final long MILLIS_SECOND = 1000;
    public static final long MILLIS_MINUTE = 60 * MILLIS_SECOND;
    public static final Long MILLIS_MINUTE_TEN = 20 * 60 * 1000L;

    @Getter
    private static String header;
    @Getter
    private static String secret;
    @Getter
    private static int expireTime;

    @Getter
    private static String loginUrl;

    @Value("${token.header}")
    public void setHeader(String header) {
        JwtConfig.header = header;
    }

    @Value(value = "${token.secret}")
    public void setSecret(String secret) {
        JwtConfig.secret = secret;
    }

    @Value("${token.expireTime}")
    public void setExpireTime(int expireTime) {
        JwtConfig.expireTime = expireTime;
    }
}
